﻿using System.Windows;
using Labthink.PCSoft.UniversalHost4.Instrument.ViewModel;

namespace Labthink.PCSoft.UniversalHost4.Instrument.Forms
{
    public partial class FrmSaveDialog 
    {
        public SaveDialogVm Vm { get; set; }

        public FrmSaveDialog()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DataContext = Vm;
            Vm.OkCmd.Execute1= _ok;
            Vm.CancelCmd.Execute1 = _cancel;
        }

        private void _cancel(object o)
        {
            Close();
        }

        private void _ok(object o)
        {
            DialogResult = true;
            Close();
        }

        private void FrmSaveDialog_OnUnloaded(object sender, RoutedEventArgs e)
        {
            Vm.OkCmd.Execute1 = null;
            Vm.CancelCmd.Execute1 = null;
        }
    }
}
